<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="reserveheader.jsp"%>
<%
	List<HashMap> list = null;
	if(request.getAttribute("list") != null){
		list = (List<HashMap>)request.getAttribute("list");
	}
	Calendar currcal = Calendar.getInstance();
	Calendar cal = Calendar.getInstance();
	
	int curryr = currcal.get(Calendar.YEAR);
	int currmon = currcal.get(Calendar.MONTH); 
	int trcount = 1;
	int yr = cal.get(Calendar.YEAR);
	int mon = cal.get(Calendar.MONTH);
	int day = cal.get(Calendar.DATE);
	
	if(request.getParameter("year") != null){
		yr = Integer.parseInt(request.getParameter("year"));
	}
	if(yr<curryr-1){
		yr = curryr-1;
	}else if(yr>curryr+2){
		yr = curryr+2;
	}
	if(request.getParameter("month") != null){
		mon = Integer.parseInt(request.getParameter("month"));
	}
	if(mon<0){
		mon = 0;
	}else if(mon>11){
		mon = 11;
	}
	
	cal.set(yr, mon, 1);
	
	int dayweek = cal.get(Calendar.DAY_OF_WEEK);
	int daymax = cal.getActualMaximum(Calendar.DATE);
	cal.set(Calendar.DATE,daymax);
	int daylastweek = cal.get(Calendar.DAY_OF_WEEK);
%>
<script language="javascript">
	function Move(yr,mon){
		var movedata = document.movedata;
		movedata.year.value = yr;
		movedata.month.value = mon;
		movedata.action="<%=path%>/reservepage.rv";
		movedata.method="post";
		movedata.submit();
	}
	function ReserveMove(yr,mon,day,room) {
		var movedata = document.movedata;
		movedata.year.value = yr;
		movedata.month.value = mon;
		movedata.day.value = day;
		movedata.room.value = room;
		movedata.action="<%=path%>/reserveform.rv";
		movedata.method="post";
		movedata.submit();
	}
</script>
<form name="movedata">
	<input type="hidden" name="year">
	<input type="hidden" name="month">
	<input type="hidden" name="day">
	<input type="hidden" name="room">
</form>
		<div id="real_contents">
			<div id="okdate_text2">
				☞ 예약을 원하시는 날짜의 객실을 클릭하시면 해당객실을 예약하실 수 있습니다<br>☞ 여러객실을 한번에 예약하실
				경우에는 해당 일자를 클릭하시면 됩니다
			</div>
			<div id="big_calendar">
				<div id="big_date">
					<table cellpadding="0" cellspacing="0" border="0" width="100%"
						summary="">
						<colgroup>
							<col width="13%">
							<col width="13%">
							<col width="48%">
							<col width="13%">
							<col width="13%">
						</colgroup>
						<tbody>
							<tr>
								<td>
									<a href="javascript:Move(<%=yr-1%>,<%=mon%>)">
									<img src="<%=path%>/images/pre02.gif" border="0" alt=""> 이전년도</a>
								</td>
								<td>
									<a href="javascript:Move(<%=yr%>,<%=mon-1%>)">
									<img src="<%=path%>/images/pre01.gif" border="0" alt=""> 이전달</a>
								</td>
								<td>
									<strong><span class="Year_B"><%=yr%>년</span>
									<span class="Month_B"><%=mon+1 %>월</span></strong>
								</td>
								<td>
									<a href="javascript:Move(<%=yr%>,<%=mon+1%>)">다음달
									<img src="<%=path%>/images/next01.gif" border="0" alt=""></a>
								</td>
								<td>
									<a href="javascript:Move(<%=yr+1%>,<%=mon%>)">다음년도
									<img src="<%=path%>/images/next02.gif" border="0" alt=""></a>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="icon_type">
					<img src="<%=path%>/images/room_no.gif" border="0" alt=""> :
					예약가능 <img src="<%=path%>/images/room_wait.gif" border="0" alt="">
					: 예약대기 <img src="<%=path%>/images/room_yes.gif" border="0" alt="">
					: 예약완료 <img src="<%=path%>/images/room_tel.gif" border="" alt="">
					: 전화문의
				</div>
				<div id="calendar_cell">
					<table cellpadding="0" cellspacing="0" border="0" width="100%"
						class="big_caltable" summary="">
						<colgroup>
							<col width="14.3%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.3%">
						</colgroup>
						<thead>
							<tr>
								<th><img src="<%=path%>/images/mt01.gif" alt=""></th>
								<th><img src="<%=path%>/images/mt02.gif" alt=""></th>
								<th><img src="<%=path%>/images/mt03.gif" alt=""></th>
								<th><img src="<%=path%>/images/mt04.gif" alt=""></th>
								<th><img src="<%=path%>/images/mt05.gif" alt=""></th>
								<th><img src="<%=path%>/images/mt06.gif" alt=""></th>
								<th><img src="<%=path%>/images/mt07.gif" alt=""></th>
							</tr>
						</thead>
					</table>
					<table cellpadding="0" cellspacing="0" border="0" width="100%"
						class="big_caltable2" summary="">
						<colgroup>
							<col width="14.3%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.28%">
							<col width="14.3%">
						</colgroup>
						<tbody>
						
						<%for(int i=1;i<dayweek;i++){%>
							<%if(trcount == 1){%>
							<tr>
							<%}%>
								<td valign="top">
									<table cellspacing="0" cellpadding="0" border="0" width="100"
										class="day_caltable" summary="">
										<colgroup>
											<col width="20%">
											<col width="80%">
										</colgroup>
										<tbody>
											<tr>
												<td class="border_Rno borderBno "><span class=""></span>
												</td>
												<td class="border_Rno borderBno"></td>
											</tr>

										</tbody>
									</table>
								</td>
							<%if(trcount==7){ trcount=0;%>
							</tr>
							<%} trcount++;%>
						<%}
						for(int i=1;i<=daymax;i++){%>
							<%if(trcount == 1){%>
							<tr>
							<%}%>
								<td valign="top">
									<table cellspacing="0" cellpadding="0" border="0" width="100"
										class="day_caltable" summary="">
										<colgroup>
											<col width="20%">
											<col width="80%">
										</colgroup>
										<tbody>
											<tr>
												<td class="border_Rno borderBno valid">
												<%if(dayweek%7==0){ dayweek++;%>
													<span class="saturday"><%=i %></span>
												<%}else if(dayweek%7==1){ dayweek++;%>
												<span class="sunday"><%=i %></span>
												<%}else{ dayweek++;%>
												<span class="weekday"><%=i %></span>
												<%}%>
												</td>
												<td class="border_Rno borderBno"></td>
											</tr>

											<tr>
												<%
												if(curryr>yr || (curryr==yr && currmon>mon) || (curryr==yr && currmon==mon & i<day)){%>
													<td class="border_Rno borderBno" colspan="2">숙박종료</td>
												<%}else{
													if(list!=null){
														for(int j=0;j<list.size();j++){%>
															<tr>
																<td class="border_Rno borderBno" colspan="2">
																<img src="<%=path %>/images/room_no.gif" border="0" alt="">
																<a onclick="javascript:ReserveMove('<%=yr%>','<%=mon %>','<%=i%>','<%=list.get(j).get("R_NO") %>')" style="cursor: hand"><%=list.get(j).get("R_NAME") %></a>
																</td>
															</tr>
												<%		}
													}
												}%>
											</tr>

										</tbody>
									</table>
								</td>
							<%if(trcount==7){ trcount=0;%>
							</tr>
							<%} trcount++;%>
						<%}
						for(int i=1;i<=7-daylastweek;i++){%>
							<%if(trcount == 1){%>
							<tr>
							<%}%>
								<td valign="top">
									<table cellspacing="0" cellpadding="0" border="0" width="100"
										class="day_caltable" summary="">
										<colgroup>
											<col width="20%">
											<col width="80%">
										</colgroup>
										<tbody>
											<tr>
												<td class="border_Rno borderBno "><span class=""></span>
												</td>
												<td class="border_Rno borderBno"></td>
											</tr>

										</tbody>
									</table>
								</td>
							<%if(trcount==7){ trcount=0;%>
							</tr>
							<%} trcount++;%>
						<%}%>
					</tbody>
					</table>
				</div>
				<div class="icon_type2"></div>
			</div>
			<!--본문끝-->
<!-- 			<div id="stpe05_next"></div> -->
<!-- 			<iframe name="eventFm" frameborder="0" width="0" height="0" -->
<!-- 				src="http://h-ps011u.monowebs.co.kr/popup/index.php?mode=realmain"></iframe> -->
<!-- 		</div> -->
<%@ include file="reservefooter.jsp"%>